home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Arashi 1.1 Source / For your think c folder / Juri's Class Library / Numbers.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-04  |  1.3 KB  |  81 lines  |  [TEXT/KAHL]

  1. /*/
  2.      Project Arashi: Numbers.c
  3.      Major release: Version 1.1, 7/22/92
  4.  
  5.      Last modification: Sunday, April 4, 1993, 2:55
  6.      Created: Sunday, November 15, 1992, 21:06
  7.  
  8.      Copyright © 1992-1993, Juri Munkki
  9. /*/
  10.  
  11. /*
  12. **    Some floating point number conversion utilies.
  13. */
  14.  
  15. #include "Numbers.h"
  16.  
  17. long double    StringToLongDouble(
  18.     StringPtr    pstr)
  19. {
  20. #if !__option(mc68881) && __option(native_fp)
  21.     return str2num(pstr);
  22. #else
  23.     extended    temp;
  24.     long double    result;
  25.     
  26.     temp = str2num(pstr);
  27.     x80tox96(&temp, &result);
  28.     return result;
  29. #endif
  30. }
  31.  
  32. NumberClass    FindNumClass(
  33.     long double    n)
  34. {
  35. #if !__option(mc68881) && __option(native_fp)
  36.     return classextended(n);
  37. #else
  38.     extended    temp;
  39.     
  40.     x96tox80(&n, &temp);
  41.     return classextended(temp);
  42. #endif
  43. }
  44.  
  45. long double    MakeNaN(
  46.     short    n)
  47. {
  48. #if !__option(mc68881) && __option(native_fp)
  49.     return nan(n);
  50. #else
  51.     extended    temp;
  52.     long double    result;
  53.     
  54.     temp = nan(n);
  55.     x80tox96(&temp, &result);
  56.     return result;
  57. #endif
  58.  
  59. }
  60.  
  61. void    NumberToDecimalRecord(
  62.     long double        number,
  63.     decimal            *decimalRecord,
  64.     int                howManyDecimals)
  65. {
  66.     decform        myDecForm;
  67.     extended    temp;
  68.     
  69.     myDecForm.style = 1;
  70.     myDecForm.digits = howManyDecimals;
  71.     decimalRecord->exp = 0;
  72.  
  73. #if !__option(mc68881) && __option(native_fp)
  74.     num2dec(&myDecForm,number,decimalRecord);
  75. #else
  76.     
  77.     x96tox80(&number, &temp);
  78.     num2dec(&myDecForm, temp, decimalRecord);
  79. #endif
  80. }
  81.